import {request} from "../utils/index.jsx";
// 获取频道列表
export function getChannelsAPI() {
    return request({
        url: '/channels/list',
        method: 'get'
    })
}

// 提交文章表单
export function submitArticleAPI(data) {
    return request({
        url: '/articles',
        method: 'post',
        data
    })
}
// 上传图片
export function uploadImageAPI(file) {
    const formData = new FormData();
    formData.append('image', file);

    return request({
        url: '/upload',  // 根据实际接口调整
        method: 'post',
        data: formData,
    });
}

// 获取文章列表
export function getArticleListAPI(params) {
    return request({
        url: '/articles/list',
        method: 'get',
        params,
    })
}

// 删除文章
export function deleteArticleAPI(id) {
    return request({
        url: `/articles/${id}`,
        method: 'delete',
    })
}

// 获取文章详情
export function getArticleDetailAPI(id) {
    return request({
        url: `/articles/${id}`,
        method: 'get',
    })
}

// 更新文章
export function updateArticleAPI(id, data) {
    return request({
        url: `/articles/${id}`,
        method: 'put',
        data,
    })
}